﻿using System.ComponentModel.DataAnnotations;
using NetSurveillance.WebApp.DataServices.Resources;
using ServiceStack.DataAnnotations;

namespace NetSurveillance.WebApp.DataServices.Models
{
    [Alias("IpSettings")]
    public class IpSetting : BaseModel
    {
        [AutoIncrement]
        public long Id { get; set; }

        [Display(Name = "DeviceName", ResourceType = typeof(ModelResource))]
        [StringLength(30)]
        public string DeviceName { get; set; }

        [Display(Name = "IP", ResourceType = typeof(ModelResource))]
        [RegularExpression(@"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$", ErrorMessage = "IP格式不正确")]
        [Required(AllowEmptyStrings = false)]
        [StringLength(32)]
        public string Ip { get; set; }

        [Display(Name = "SubnetMask", ResourceType = typeof(ModelResource))]
        [RegularExpression(@"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$", ErrorMessage = "IP格式不正确")]
        [Required(AllowEmptyStrings = false)]
        [StringLength(32)]
        public string SubnetMask { get; set; }

        [Display(Name = "Gateway", ResourceType = typeof(ModelResource))]
        [RegularExpression(@"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$", ErrorMessage = "IP格式不正确")]
        [Required(AllowEmptyStrings = false)]
        [StringLength(32)]
        public string Gateway { get; set; }
    }
}